package com.cc2019.buke.type.frag;

import android.content.Context;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.cc2019.buke.R;
import com.cc2019.buke.type.adapter.WaiguoTypeAdapter;
import com.cc2019.buke.type.entry.TypeC;
import com.cc2019.buke.type.entry.TypeW;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnLoadMoreListener;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;

import java.util.ArrayList;
import java.util.List;

public class TypeWFragment extends Fragment {
    private RecyclerView recyclerView;
    private View view;
    private Context context;
    private WaiguoTypeAdapter adapter;
    private static final int REFRESH = 0;
    private static final int LOADING = 1;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view =inflater.inflate(R.layout.fragment_type_w, container, false);

        recyclerView = view.findViewById(R.id.my_RecyViewW);
        context = this.getContext();

        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Context context = this.getContext();
        List<TypeW> typew_list = init();
        GridLayoutManager gridLayoutManager = new GridLayoutManager(context,3);
        recyclerView.setLayoutManager(gridLayoutManager);
        adapter=new WaiguoTypeAdapter(typew_list,context);
        recyclerView.setAdapter(adapter);
    }

    public List<TypeW> init() {
        ArrayList<TypeW> pros = new ArrayList<>();
        TypeW typeW = new TypeW();
        TypeW typeW1=new TypeW(R.drawable.w1,"爱丽丝漫游奇境记");
        TypeW typeW2=new TypeW(R.drawable.w2,"茶花女");
        TypeW typeW3=new TypeW(R.drawable.w3,"地心游记");
        TypeW typeW4=new TypeW(R.drawable.w4,"飞鸟集");
        TypeW typeW5=new TypeW(R.drawable.w5,"昆虫记");
        TypeW typeW6=new TypeW(R.drawable.w6,"宽容");
        TypeW typeW7=new TypeW(R.drawable.w7,"鲁滨逊漂流记");
        TypeW typeW8=new TypeW(R.drawable.w8,"童年");
        TypeW typeW9=new TypeW(R.drawable.w9,"莫泊桑短篇小说集");
        TypeW typeW10=new TypeW(R.drawable.w10,"魔幻城堡");
        TypeW typeW11=new TypeW(R.drawable.w11,"欧·亨利短篇小说选");
        TypeW typeW12=new TypeW(R.drawable.w12,"傲慢与偏见");
        TypeW typeW13=new TypeW(R.drawable.w13,"人生的枷锁");
        TypeW typeW14=new TypeW(R.drawable.w14,"时间机器");
        TypeW typeW15=new TypeW(R.drawable.w15,"假如给我三天光明");
        TypeW typeW16=new TypeW(R.drawable.w16,"一千零一夜");
        TypeW typeW17=new TypeW(R.drawable.w17,"雾都孤儿");
        TypeW typeW18=new TypeW(R.drawable.w18,"希腊神话");
        TypeW typeW19=new TypeW(R.drawable.w19,"小王子");
        TypeW typeW20=new TypeW(R.drawable.w20,"红与黑");
        TypeW typeW21=new TypeW(R.drawable.w21,"基督山伯爵");
        TypeW typeW22=new TypeW(R.drawable.w22,"虹");
        TypeW typeW23=new TypeW(R.drawable.w23,"了不起的盖茨比");
        TypeW typeW24=new TypeW(R.drawable.w24,"爱玛");
        pros.add(typeW1);pros.add(typeW2);pros.add(typeW3);pros.add(typeW4);pros.add(typeW5);pros.add(typeW6);pros.add(typeW7);
        pros.add(typeW8);pros.add(typeW9);pros.add(typeW10);pros.add(typeW11);pros.add(typeW12);pros.add(typeW13);
        pros.add(typeW14);pros.add(typeW15);pros.add(typeW16);pros.add(typeW17);pros.add(typeW18);
        pros.add(typeW19);pros.add(typeW20);pros.add(typeW21);pros.add(typeW22);
        pros.add(typeW23);pros.add(typeW24);
        return pros;
    }

}